home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs32.d81 / examples.arc / TYPE.A < prev    next >
Text File  |  1989-12-01  |  4KB  |  107 lines

  1. ; type.asm
  2. ;--------------------------------------------------
  3. ; command:  type/x <[d]:filename>
  4. ;--------------------------------------------------
  5.                                   
  6. status      = $0090               
  7. stkey       = $0091               
  8. poker       = $0016               
  9. color       = $00f1               
  10. int08       = $1708               
  11. int0c       = $170c               
  12. int0d       = $170d               
  13. int0e       = $170e               
  14. sw1         = $1bfc               
  15. hexa        = $b8c2               
  16. chkin       = $ffc6               
  17. chrout      = $ffd2               
  18. chrin       = $ffcf
  19.  
  20. Right       = 29
  21.                                   
  22. star        = $0b00               
  23.             .wor star             
  24.             * = star              
  25.  
  26.             jmp type
  27.             dw  Date
  28.                       
  29. type        ldx #1                ; input from %1
  30.             lda #0                ; don't care what file type
  31.             jsr int08             ; open for read and abort on error
  32.             bcs typxx             ; disk error on open...abort
  33.             jsr chkin             
  34.             bcs typxxx            ; abort if error
  35. ty0         jsr chrin             ; get char
  36.             ldy status            
  37.             jsr cvt               
  38.             bit stkey             ; test stop key
  39.             bpl typx              ; its down...quit
  40.             tya                   ; was st=0?
  41.             beq ty0               ; ok...keep typing
  42.             bne typx              ; done..exit
  43. typxxx      jsr int0c             ; read ds$
  44. typxx       jsr int0d             ; print it
  45. typx        jmp int0e             ; close all and quit
  46.                                   
  47. cvt         pha                   
  48.             lda sw1               
  49.             cmp #"p"                ; /p convert ASCII to PETSCII
  50.             beq a2p               
  51.             cmp #"a"                ; /a convert PETSCII to ASCII
  52.             beq p2a               
  53.             cmp #"s"                ; /s show as screen code
  54.             beq screen            
  55.             cmp #"h"                ; /h show as hex bytes
  56.             beq hex               
  57.             pla                   
  58.             jmp chrout            
  59.                                   
  60. screen      pla                   
  61.             sty poker             
  62.             ldx color             
  63.             jsr $c003             
  64.             lda #Right
  65.             jsr $c00c             
  66.             ldy poker             
  67.             rts                   
  68.                                   
  69. hex         pla                   
  70.             jmp hexa              
  71.                                   
  72. p2a         pla                   
  73.             cmp #"a"              ; petscii to ascii
  74.             bcc p2ax              
  75.             cmp #$5b              
  76.             bcs p2a2              
  77.             ora #$20              
  78.             bne p2ax              
  79.                                   
  80. p2a2        cmp #$c1              
  81.             bcc p2ax              
  82.             cmp #$db              
  83.             bcs p2ax              
  84.             and #$7f              
  85. p2ax        jmp chrout            
  86.                                   
  87. a2p         pla                   
  88.             cmp #"a"              ; ascii to petscii
  89.             bcc a2px              
  90.             cmp #$5b              
  91.             bcs a2p2              
  92.             ora #$80              
  93.             bne a2px              
  94.                                   
  95. a2p2        cmp #$61              
  96.             bcc a2px              
  97.             cmp #$7b              
  98.             bcs a2px              
  99.             and #$df              
  100. a2px        cmp #10               
  101.             bne a2pxx             
  102.             rts                   
  103.                                   
  104. a2pxx       jmp chrout            
  105.                                   
  106.             .end                  
  107.